Skip to content

Conversation

@alex-spies
Copy link
Contributor

This class is confusing:

  • It contains an unused cluster attribute - we never separate out the cluster, it remains in the index field. Also, in the constructor, this field is called catalog, which is a concept entirely absent from ESQL at the moment.
  • It can refer to multiple indices, even multiple wildcard patterns, but doesn't mention this neither in its name nor javadoc.
  • It has little to do with tables, which is likely a remnant of this class' usage in SQL, before the esql.core split.

This PR removes the cluster attribute, renames the class to IndexPattern, and adds javadoc to clarify that it can also contain stuff like remote1:idx1,remote-*:idx-*.

@alex-spies alex-spies added >refactoring auto-backport Automatically create backport pull requests when merged :Analytics/ES|QL AKA ESQL v9.0.0 v8.18.0 labels Jan 24, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jan 24, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@alex-spies alex-spies requested a review from bpintea January 24, 2025 14:11
import org.elasticsearch.xpack.esql.plan.TableIdentifier;
import org.elasticsearch.xpack.esql.plan.IndexPattern;

public class TableInfo {
Copy link
Contributor Author

@alex-spies alex-spies Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a future PR, I think this class just has to go. It is a wrapper around TableIdentifier, except that it throws away the equality/hash methods and uses instance identity for equality.


import static org.elasticsearch.transport.RemoteClusterAware.REMOTE_CLUSTER_INDEX_SEPARATOR;

public class TableIdentifier {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't show properly in the diff, but the changes here are simple:

  • Rename to IndexPattern
  • Remove the cluster/catalog field (entirely unused, was always null in all constructor calls)
  • Remove the cluster() and qualifiedIndex methods (both entirely unused)
  • Adapt equals and hashCode

public class IndexPattern {

private final Source source;
private final String indexPattern;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be called indexPattern(s) as it might list coma separated patterns?

Not sure if it is needed often, but #120277 would benefit if it is possible to return list/array of separate patterns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add a helper method as part of #120277! I'd like to not add logic in this PR, so it remains a straight refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, yeah, indexPatterns (plural) would be even more precise - but then we'd have to align e.g. EsRelation as well. And it's also reasonable to consider idx,logs-* a single pattern which matches idx and anything starting with logs-.

Rename IndexPattern.index to indexPattern and UnresolvedRelation.table
to indexPattern.
@alex-spies alex-spies added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jan 24, 2025
@elasticsearchmachine elasticsearchmachine merged commit 060c833 into elastic:main Jan 24, 2025
16 checks passed
@alex-spies alex-spies deleted the simplify_table_class branch January 24, 2025 17:01
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 120797

idegtiarenko pushed a commit to idegtiarenko/elasticsearch that referenced this pull request Jan 27, 2025
…c#120797)

This class is confusing: - It contains an **unused** `cluster` attribute
- we never separate out the cluster, it remains in the `index` field.
Also, in the constructor, this field is called `catalog`, which is a
concept entirely absent from ESQL at the moment. - It can refer to
multiple indices, even multiple wildcard patterns, but doesn't mention
this neither in its name nor javadoc. - It has little to do with tables,
which is likely a remnant of this class' usage in SQL, before the
`esql.core` split.

This PR removes the `cluster` attribute, renames the class to
`IndexPattern`, and adds javadoc to clarify that it can also contain
stuff like `remote1:idx1,remote-*:idx-*`.

(cherry picked from commit 060c833)
elasticsearchmachine pushed a commit that referenced this pull request Jan 27, 2025
… (#120884)

This class is confusing: - It contains an **unused** `cluster` attribute
- we never separate out the cluster, it remains in the `index` field.
Also, in the constructor, this field is called `catalog`, which is a
concept entirely absent from ESQL at the moment. - It can refer to
multiple indices, even multiple wildcard patterns, but doesn't mention
this neither in its name nor javadoc. - It has little to do with tables,
which is likely a remnant of this class' usage in SQL, before the
`esql.core` split.

This PR removes the `cluster` attribute, renames the class to
`IndexPattern`, and adds javadoc to clarify that it can also contain
stuff like `remote1:idx1,remote-*:idx-*`.

(cherry picked from commit 060c833)

Co-authored-by: Alexander Spies <[email protected]>
@idegtiarenko idegtiarenko mentioned this pull request Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.18.0 v9.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants